﻿@using KPIS.GERP.Models.ICM
@model PurchaseOrderInstallment

@{
    ViewBag.Title = "Details";
    Layout = "~/Views/Shared/_EmptyLayout.cshtml";
    var serviceDN = new KPIS.GERP.WEB.GIMS.DeliveryNoteService.DeliveryNoteServiceClient();
}

@if (Model == null)
{
    <div class="alert alert-block alert-error">ไม่มีข้อมูลการแบ่งงวด (#@ViewBag.HeaderPoId)</div>
} else
{
    <div class="block-button-menu-above">
        
        @{
            var routeValue = new {id = Model.PoInstallId, HeaderPoId = Model.PoId};
        }

        @Html.ButtonViewAll(routeValue)

        @if (serviceDN.SelectDeliveryNote(new DeliveryNote() { PoInstallId = Model.PoInstallId, RecordStatus = "!" + RecordStatus.DeletedStatus }, null).ToList().Count == 0)
        {
            @Html.ButtonEdit(routeValue)
            @Html.ButtonAdd(routeValue)
            @Html.ButtonDelete(routeValue)
        }

    </div>

    @Html.Partial("_DetailsForm")
    
    @*<iframe id="iframe1" src="@Url.Action("Index", "InstallmentItem", new {poInstallId=Model.PoInstallId})" 
        style="width:100%; border: none;"></iframe>*@
}


@section scripts
{
    <script>
        $(function() {
            var lastHeight1 = 0, curHeight1 = 0, $frame1 = $('#iframe1');
            setInterval(function() {
                curHeight1 = $frame1.contents().find('body').height() + 40;
                if (curHeight1 != lastHeight1) {
                    $frame1.css('height', (lastHeight1 = curHeight1) + 'px');
                }
            }, 500);
        });

    </script>
}